<?php
// Set flag that this is a parent file.
define('_JEXEC', 1);
define('DS', DIRECTORY_SEPARATOR);

if (file_exists(dirname(__FILE__) . '/defines.php')) {
	include_once dirname(__FILE__) . '/defines.php';
}

if (!defined('_JDEFINES')) {
	define('JPATH_BASE', dirname(__FILE__));
	require_once JPATH_BASE.'/includes/defines.php';
}
require_once ('./configuration.php');
require_once (JPATH_BASE . '/administrator/components/com_manager/helpers/manager.php');

updateStatusProduct();

function updateStatusProduct() {	
	$JConfig = new JConfig;
	$conn = mysql_connect($JConfig->host, $JConfig->user, $JConfig->password) or die("false:Connecting database failed");
	
	mysql_select_db($JConfig->db, $conn) or die("false:Selecting database failed");
	mysql_query("set names 'utf8'", $conn);
	
	$now = date('Y-m-d', time());
	
	$query = 'UPDATE tbl_product SET status='.ManagerHelper::PRODUCT_STATUS_EXPIRED;
	$query.= ' WHERE expired_date < "' . $now . '"'; 
	
	$q = mysql_query($query) or die("false:Service error");
}

exit;
?>